<template>
  <div class="yongjinguanli">
    <div v-if="!shoujiban">
      <left></left>
      <div class="right">
        <div
          style="
            height: 91px;
            border-bottom: 1px solid rgb(227, 232, 241);
            width: 100%;
            padding: 0 30px;
          "
          class="flexbc"
        >
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/yongjin' }"
              >佣金结算</el-breadcrumb-item
            >
            <el-breadcrumb-item>佣金结算订单管理</el-breadcrumb-item>
          </el-breadcrumb>
          <top></top>
        </div>
        <div
          style="
            padding: 37px 30px 0 30px;
            height: calc(100vh - 91px);
            overflow: auto;
          "
        >
          <div
            style="
              background: rgb(255, 255, 255);
              border-radius: 20px;
              padding: 20px;
            "
            class="flexb"
          >
            <div class="flex">
              <div>
                <div style="margin-bottom: 10px">商品名称&编码</div>
                <div>
                  <el-input
                    v-model="search.gname"
                    style="width: 200px; margin-right: 30px"
                    placeholder="请输入"
                  ></el-input>
                </div>
              </div>
              <div>
                <div style="margin-bottom: 10px">订单ID</div>
                <div>
                  <el-input
                    v-model="search.order_no"
                    style="width: 200px; margin-right: 30px"
                    placeholder="请输入"
                  ></el-input>
                </div>
              </div>
              <div>
                <div style="margin-bottom: 10px">生产号码</div>
                <div>
                  <el-input
                    v-model="search.plan_mobile_produce"
                    style="width: 200px; margin-right: 30px"
                    placeholder="请输入"
                  ></el-input>
                </div>
              </div>
              <div>
                <div style="margin-bottom: 10px">发展人</div>
                <div>
                  <el-input
                    v-model="search.share_name"
                    style="width: 200px; margin-right: 30px"
                    placeholder="请输入"
                  ></el-input>
                </div>
              </div>
              <div>
                <div style="margin: 10px 0">所属一级分销商</div>
                <div>
                  <el-input
                    v-model="search.merchant_name"
                    style="width: 200px; margin-right: 30px"
                    placeholder="请输入"
                  ></el-input>
                </div>
              </div>
              <div>
                <div style="margin: 10px 0">触发方式</div>
                <div>
                  <el-select
                    clearable
                    filterable
                    style="width: 200px; margin-right: 30px"
                    v-model="search.settlement_conditions"
                    placeholder="请选择触发方式"
                  >
                    <el-option label="人工结算" value="0"></el-option>
                    <el-option label="自动结算" value="1"></el-option>
                  </el-select>
                </div>
              </div>
              <!-- <div>
                  <div style="margin-bottom: 10px;">所属一级分销商</div>
                  <div><el-input v-model="search.merchant_name" style="width: 200px; margin-right: 30px;" placeholder="请输入"></el-input></div>
                </div> -->

              <div>
                <div style="margin: 10px 0">订单创建时间</div>
                <div class="flexc">
                  <el-date-picker
                    v-model="times2"
                    @change="changetimes2"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    style="margin-right: 30px; width: 380px"
                    type="datetimerange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                  ></el-date-picker>
                </div>
              </div>
              <div>
                <div style="margin: 10px 0">导入时间</div>
                <div class="flexc">
                  <el-date-picker
                    v-model="times"
                    @change="changetimes"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    style="margin-right: 30px; width: 380px"
                    type="datetimerange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                  ></el-date-picker>
                </div>
              </div>
              <div style="margin-right: 30px">
                <div style="margin-top: 20px">&nbsp;</div>
                <div>
                  <el-button
                    type="primary"
                    round
                    icon="el-icon-search"
                    @click="sousuo"
                    >检索</el-button
                  >
                  <el-button
                    type="primary"
                    round
                    icon="el-icon-setting"
                    @click="zidongjieusan"
                    >自动结算</el-button
                  >
                </div>
              </div>
            </div>
          </div>
          <div class="flexbc" style="padding: 20px 0">
            <div class="flexc">
              <div style="margin-right: 20px">
                <el-button
                  type="primary"
                  round
                  icon="el-icon-plus"
                  @click="daoruyanzheng"
                  >导入触发支出订单</el-button
                >

                <el-upload
                  :show-file-list="false"
                  action="#"
                  ref="upload"
                  :http-request="uploasd"
                  v-show="false"
                >
                  <el-button type="primary" round icon="el-icon-plus"
                    >导入触发支出订单</el-button
                  >
                </el-upload>
              </div>
              <div style="margin-right: 20px">
                <el-button round @click="piliangkai">批量支出结算</el-button>
              </div>
              <div style="margin-right: 20px">
                <el-button round @click="xiazai">导出待结算明细</el-button>
              </div>
              <div>
                <el-button type="text" @click="down">模板下载</el-button>
              </div>
            </div>

            <div>
              <el-button type="text" @click="shezhimima"
                >设置结算导入密码</el-button
              >
            </div>
          </div>

          <el-table
            :data="list"
            style="width: 100%"
            ref="multipleTable"
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              type="selection"
              width="55"
              fixed
            ></el-table-column>
            <el-table-column
              show-overflow-tooltip="true"
              width="240"
              align="center"
              prop="order_no"
              label="订单ID"
            ></el-table-column>
            <el-table-column
              show-overflow-tooltip="true"
              align="center"
              width="160"
              prop="plan_mobile_produce"
              label="生产号码"
            ></el-table-column>
            <el-table-column
              align="center"
              prop="share_name"
              label="发展人"
            ></el-table-column>
            <el-table-column
              width="200"
              align="center"
              prop="merchant_name"
              label="所属一级分销商"
            ></el-table-column>
            <el-table-column
              show-overflow-tooltip="true"
              width="200"
              align="center"
              prop="goods_name"
              label="商品名称"
            ></el-table-column>
            <el-table-column
              width="180"
              align="center"
              prop="active_status"
              label="激活状态"
            >
              <template slot-scope="scope">
                <div
                  v-if="scope.row.active_status == 0"
                  style="color: rgb(9, 134, 0)"
                >
                  未激活
                </div>
                <div
                  v-if="scope.row.active_status == 100"
                  style="color: rgb(9, 134, 0)"
                >
                  已激活
                </div>
                <div
                  v-if="scope.row.active_status == 200"
                  style="color: rgb(9, 134, 0)"
                >
                  激活且充值
                </div>
              </template>
            </el-table-column>
            <el-table-column
            width="200"
              align="center"
              prop="commission"
              label="待支出佣金金额(元)"
            ></el-table-column>
            <el-table-column
            width="200"
              align="center"
              prop="order_at"
              label="订单创建时间"
            ></el-table-column>
            <el-table-column
            width="200"
              align="center"
              prop="updated_at"
              label="导入时间"
            ></el-table-column>
            <el-table-column align="center" prop="ok" label="是否结算佣金" width="200">
              <template slot-scope="scope">
                <div v-if="scope.row.ok == 1" style="color: rgb(9, 134, 0)">
                  满足支出
                </div>
                <div v-if="scope.row.ok == 0" style="color: rgb(236, 82, 1)">
                  不满足支出
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="ok" label="结算触发方式" width="200">
              <template slot-scope="scope">
                <div v-if="scope.row.settlement_conditions == 1">自动触发</div>
                <div v-if="scope.row.settlement_conditions == 0">人工导入</div>
              </template>
            </el-table-column>
            <el-table-column
            width="200"
              align="center"
              prop="settlement_type"
              label="佣金阶段类型"
            >
              <template slot-scope="scope">
                <div
                  v-if="
                    scope.row.settlement_type == 2 ||
                    scope.row.settlement_type == 1
                  "
                >
                  全部佣金
                </div>
                <div v-if="scope.row.settlement_type == 31">一阶段激活</div>
                <div v-if="scope.row.settlement_type == 32">二阶段充值</div>
              </template>
            </el-table-column>
            <el-table-column
              width="200"
              show-overflow-tooltip="true"
              align="center"
              prop="remark"
              label="失败原因"
            ></el-table-column>
            <el-table-column align="center" label="操作" fixed="right" width="120">
              <template slot-scope="scope">
                <div
                  @click="shanchu(scope.row.id)"
                  style="color: rgb(254, 61, 61); cursor: pointer"
                >
                  删除
                </div>
              </template>
            </el-table-column>
          </el-table>

          <el-pagination
            style="text-align: right; padding: 20px"
            background
            layout="prev,pager,next,total,jumper"
            :current-page="search.page"
            @current-change="fanye"
            :page-size="search.page_size"
            :total="total"
          ></el-pagination>
          <!-- <footers></footers> -->
        </div>
      </div>
    </div>
    <!-- 自动结算 -->
    <el-dialog
      title="佣金结算配置"
      :visible.sync="yongjinjiesuanDialog"
      width="600px"
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      :close-on-press-escape="false"
    >
      <div style="margin-top: -12px">
        <div style="display: inline">秒返商品满足结算条件后自动结算</div>
        <el-switch
          v-model="isyongjinjiesuan.autovalue"
          @change="changeSwitch($event, row)"
        >
        </el-switch>
      </div>
      <div style="margin-top: 20px">
        开启后，该订单的激活状态符合结算佣金要求后佣金按照预设条件自动结算给分销商，无需审核支出，请谨慎
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button round @click="undoyongjinjiesuan">取消</el-button>
        <el-button type="primary" round @click="yongjinjiesuan">确认</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="批量支出结算"
      :visible.sync="log"
      width="440px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <div>
        <div style="margin-bottom: 20px; font-size: 16px">
          <el-radio v-model="zhichu_type" :label="0"
            >结算按当前选择的条数：{{ multipleSelection.length }}条</el-radio
          >
        </div>
        <div style="margin-bottom: 20px; font-size: 16px">
          <el-radio v-model="zhichu_type" :label="1"
            >结算当前检索的全量结果：{{ total }}条</el-radio
          >
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button round @click="log = false">关闭</el-button>
        <el-button round type="primary" @click="piliang">确定</el-button>
      </span>
    </el-dialog>

    <div
      v-if="shoujiban"
      style="
        color: rgb(2, 12, 29);
        font-size: 0.24rem;
        background: #f6f8fb;
        padding-top: 1rem;
      "
    >
      <topandleft></topandleft>
      <div style="background: #fff; padding: 0.3rem">
        <div class="flexc" style="margin-bottom: 0.3rem">
          <div
            style="
              width: 2px;
              height: 0.2rem;
              background: rgb(2, 12, 29);
              margin-right: 10px;
              overflow: hidden;
            "
          ></div>
          <div style="font-size: 0.36rem; font-weight: bold">佣金结算</div>
        </div>
        <div class="flexc" style="margin-bottom: 0.3rem">
          <div style="color: rgb(175, 179, 188)">首页</div>
          <div style="margin: 0 0.2rem; color: rgb(175, 179, 188)">·</div>
          <div style="color: rgb(175, 179, 188)">佣金结算</div>
          <div style="margin: 0 0.2rem; color: rgb(175, 179, 188)">·</div>
          <div>佣金结算订单管理</div>
        </div>
      </div>
      <div style="padding: 0.3rem">
        <div style="background: #fff; border-radius: 0.2rem; padding: 0.3rem">
          <div class="flexc" style="margin-bottom: 0.2rem">
            <el-input
              v-model="search.gname"
              placeholder="请输入商品名称&编码"
            ></el-input>
          </div>
          <div class="flexc" style="margin-bottom: 0.2rem">
            <el-input
              v-model="search.order_no"
              placeholder="请输入订单ID"
            ></el-input>
          </div>
          <div class="flexc" style="margin-bottom: 0.2rem">
            <el-input
              v-model="search.merchant_name"
              placeholder="请输入分销商名称"
            ></el-input>
          </div>
          <!--          <div class="flexc" style="margin-bottom: 0.2rem;">
            <el-date-picker v-model="search.start" style="width: 100%;" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择导入开始时间"></el-date-picker>
          </div>
          <div class="flexc" style="margin-bottom: 0.2rem;">
            <el-date-picker v-model="search.end" style="width: 100%;" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择导入结束时间"></el-date-picker>
          </div>
          -->
          <div class="flexbc" style="margin-bottom: 0.2rem">
            <div
              class="datashow"
              @click="xuanshijianshow(1)"
              style="color: #c0c4cc"
              v-if="!search.start"
            >
              请选择开始日期
            </div>
            <div
              class="datashow"
              @click="xuanshijianshow(1)"
              v-if="search.start"
            >
              {{ search.start }}
            </div>
            <div>~</div>
            <div
              class="datashow"
              @click="xuanshijianshow(2)"
              style="color: #c0c4cc"
              v-if="!search.end"
            >
              请选择结束日期
            </div>
            <div class="datashow" @click="xuanshijianshow(2)" v-if="search.end">
              {{ search.end }}
            </div>
          </div>
          <van-popup v-model="showdate" round position="bottom">
            <van-datetime-picker
              type="date"
              :min-date="minDate"
              title="选择时间"
              @confirm="xuanshijian"
              @cancel="showdate = false"
            />
          </van-popup>

          <div
            @click="sousuo"
            class="flexcc"
            style="
              background: rgb(0, 90, 255);
              height: 41px;
              border-radius: 41px;
              padding: 0 0.4rem;
              color: #fff;
            "
          >
            检索
          </div>
        </div>

        <div class="flexc" style="padding: 0.2rem 0">
          <div style="margin-right: 0.2rem; margin-bottom: 0.2rem">
            <el-upload
              :show-file-list="false"
              action="#"
              :http-request="uploasd"
            >
              <el-button type="primary" round icon="el-icon-plus"
                >导入触发支出订单</el-button
              >
            </el-upload>
          </div>
          <div style="margin-right: 0.2rem; margin-bottom: 0.2rem">
            <el-button round @click="piliangkai">批量支出结算</el-button>
          </div>
          <div style="margin-right: 0.2rem; margin-bottom: 0.2rem">
            <el-button round @click="xiazai">导出待结算明细</el-button>
          </div>
          <div style="margin-bottom: 0.2rem">
            <el-button type="text" @click="down">模板下载</el-button>
          </div>
        </div>

        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <div
            v-for="item in list"
            :key="item.id"
            style="
              background: #fff;
              padding: 0.2rem;
              margin-bottom: 0.2rem;
              border-radius: 0.2rem;
            "
          >
            <div class="flexbc" style="margin-bottom: 0.2rem">
              <div>结算时间</div>
              <div>{{ item.created_at }}</div>
            </div>
            <div class="flexbc" style="margin-bottom: 0.2rem">
              <div>满足结算订单</div>
              <div>{{ item.ok_count }}</div>
            </div>
            <div class="flexbc" style="margin-bottom: 0.2rem">
              <div>不满足结算订单</div>
              <div>{{ item.orders_count - item.ok_count }}</div>
            </div>
            <div class="flexbc" style="margin-bottom: 0.2rem">
              <div>结算金额</div>
              <div>{{ item.sum_commission }}</div>
            </div>

            <div class="flexc">
              <div
                @click="xiazai(scope.row.id)"
                style="color: rgb(0, 90, 255); cursor: pointer"
              >
                下载明细
              </div>
            </div>
          </div>
        </van-list>
      </div>
    </div>
    <!-- 失败原因 -->
    <el-dialog
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      :close-on-press-escape="false"
      title="失败订单原因"
      :visible.sync="isshowfail"
      width="500px"
    >
      <div v-for="(item, index) in failmsg" :key="index">{{ item }}</div>
      <div style="text-align: center; margin-top: 30px">
        <el-button round type="primary" @click="isshowfail = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>

    <el-dialog
      title="结算安全"
      :visible.sync="mimalog"
      width="500px"
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      :close-on-press-escape="false"
    >
      <div style="margin-bottom: 20px">
        导入触发支出订单，请输入密码以允许此次操作
      </div>
      <el-input
        v-model="chufaall.checkout_password"
        placeholder="请输入密码"
      ></el-input>
      <div
        class="flex"
        style="
          justify-content: flex-end;
          color: rgb(0, 90, 255);
          cursor: pointer;
          margin-top: 20px;
        "
        @click="shezhimima"
      >
        修改密码
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button round @click="mimalog = false">取消</el-button>
        <el-button type="primary" round @click="querenchufa">确认</el-button>
      </div>
    </el-dialog>
    <mima v-if="mimalog2" ref="mimalog2"></mima>
    <mima3 v-if="mimalog3" ref="mimalog3"></mima3>
  </div>
</template>

<script>
import mima from "./mima/mima.vue";
import mima3 from "./mima/mima2.vue";
import left from "../left.vue";
import top from "../top.vue";
import footers from "../footer.vue";
import topandleft from "../topandleft.vue";
export default {
  name: "yongjinguanli",
  components: {
    left,
    top,
    topandleft,
    footers,
    mima,
    mima3,
  },
  data() {
    return {
      log: false,
      search: {
        page: 1,
        page_size: 20,
        order_no: "",
        gname: "",
        merchant_name: "",
        share_name: "", //发展人
        start: "",
        end: "",
        c_start: "",
        c_end: "",
        plan_mobile_produce: "", //生产号码
        settlement_conditions: "",
      },
      zhichu_type: 0,
      times: [],
      times2: [],
      list: [],
      total: 0,
      widthss: false,
      multipleSelection: [],

      shoujiban: false,
      loading: false,
      finished: false,

      showdate: false,
      whodata: "",
      minDate: new Date(2023, 0, 1),
      isshowfail: false,
      failmsg: "",
      yongjinjiesuanDialog: false,
      isyongjinjiesuan: {
        autovalue: false, //0否  1是
      },
      switchshow: "",
      chufaall: {
        data: "",
        checkout_password: "",
      },
      mimalog: false,
      mimalog2: false,
      mimalog3: false,
    };
  },
  created() {
    // this.getlist()
  },
  mounted() {
    if (window.screen.width == 1920) {
      this.widthss = true;
    }
    if (window.screen.width < 1080) {
      this.shoujiban = true;
      var h = document.documentElement.clientWidth / 7.5 + "px";
      document.documentElement.style.fontSize = h;

      this.onLoad();
    } else {
      this.getlist();
    }
  },
  methods: {
    daoruyanzheng: function () {
      axios.get("/own/system/get").then((response) => {
        if (response.data.msg.code == 0) {
          this.mobile = response.data.data.mobile;

          if (response.data.data.is_checkout_pw == 1) {
            this.mimalog = true;
          } else {
            this.$refs["upload"].$children[0].$refs.input.click();
          }
        } else {
          this.$message.error(response.data.msg.info);
        }
      });
    },
    shezhimima: function () {
      axios.get("/own/system/get").then((response) => {
        if (response.data.msg.code == 0) {
          this.mobile = response.data.data.mobile;

          if (response.data.data.is_checkout_pw == 1) {
            this.mimalog2 = true;
            this.$nextTick(() => {
              this.$refs.mimalog2.log = true;
            });
          } else {
            this.mimalog3 = true;
            this.$nextTick(() => {
              this.$refs.mimalog3.log = true;
            });
          }
        } else {
          this.$message.error(response.data.msg.info);
        }
      });
    },
    xuanshijianshow: function (val) {
      if (val == 1) {
        this.showdate = true;
        this.whodata = "start";
      }
      if (val == 2) {
        this.showdate = true;
        this.whodata = "end";
      }
    },
    xuanshijian: function (val) {
      this.search[this.whodata] = moment(val).format("YYYY-MM-DD hh:mm:ss");
      this.showdate = false;
    },
    onLoad() {
      axios
        .get("/own/commission/orders", { params: this.search })
        .then((response) => {
          if (response.data.msg.code == 0) {
            if (response.data.data.data.length > 0) {
              response.data.data.data.forEach((item) => {
                this.list.push(item);
              });
              if (this.list.length >= response.data.data.data.total) {
                this.finished = true;
              } else {
                this.search.page++;
                this.loading = false;
              }
            } else {
              this.finished = true;
            }
          } else {
            this.$message.error(response.data.msg.info);
          }
        });
    },
    xiazai: function () {
      axios.post("/own/commission/orders/exp").then((response) => {
        if (response.data.msg.code == 0) {
          window.location.href = location.origin + "/" + response.data.data;
        } else {
          this.$message.error(response.data.msg.info);
        }
      });
    },
    piliangkai: function () {
      this.log = true;
    },
    piliang: function () {
      this.$confirm("确定进行批量支出结算吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        if (this.zhichu_type == 0) {
          if (this.multipleSelection.length > 0) {
            let arr = [];
            this.multipleSelection.forEach((item) => {
              arr.push(item.id);
            });
            axios
              .post(`/own/commission/orders/expend`, { ids: arr })
              .then((response) => {
                if (response.data.msg.code == 0) {
                  this.getlist();
                  this.$message.success("已批量支出结算");
                } else {
                  this.$message.error(response.data.msg.info);
                }
              });
          } else {
            this.$message.error("请选择订单");
          }
        }
        if (this.zhichu_type == 1) {
          let obj = JSON.parse(JSON.stringify(this.search));
          obj.all = 1;

          axios.post(`/own/commission/orders/expend`, obj).then((response) => {
            if (response.data.msg.code == 0) {
              this.getlist();
              this.$message.success("已批量支出结算");
            } else {
              this.$message.error(response.data.msg.info);
            }
          });
        }
      });
    },
    shanchu: function (id) {
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        axios.post(`/own/commission/order/del`, { id: id }).then((response) => {
          if (response.data.msg.code == 0) {
            this.getlist();
            this.$message.success("已删除");
          } else {
            this.$message.error(response.data.msg.info);
          }
        });
      });
    },
    changetimes: function () {
      if (this.times != null) {
        this.search.start = this.times[0];
        this.search.end = this.times[1];
      } else {
        this.search.start = "";
        this.search.end = "";
      }
    },
    changetimes2: function () {
      if (this.times2 != null) {
        this.search.c_start = this.times2[0];
        this.search.c_end = this.times2[1];
      } else {
        this.search.c_start = "";
        this.search.c_end = "";
      }
    },
    down: function () {
      const a = document.createElement("a");
      a.setAttribute("download", "导入触发支出订单.xlsx");
      a.setAttribute(
        "href",
        location.origin + "/hou/static/xlsx/chufazhichudingdan.xlsx"
      );
      a.click();
    },
    uploasd: function (file) {
      let ff = this.duwenjian(file);

      ff.then((res) => {
        let data = [];
        res.forEach((item) => {
          let obj = {
            mob: item["生产号码"],
            order_no: item["订单号"],
            upstream_order_id: item["上游订单号"],
            ok: item["是否满足结算佣金"] == "满足" ? 1 : 0,
            rmk: item["不满足原因"],
          };
          data.push(obj);
        });

        this.chufaall.data = data;

        axios
          .post("/own/commission/order/imp", this.chufaall)
          .then((response) => {
            if (response.data.msg.code == 0) {
              this.$message.success(`上传成功${response.data.data.suc}个`);
              if (response.data.data.fail.length != 0) {
                this.isshowfail = true;
                this.failmsg = response.data.data.fail;
              }
              this.sousuo();
              this.mimalog = false;
            } else {
              this.$message.error(response.data.msg.info);
            }
          });
      });
    },
    querenchufa: function () {
      this.chufaall.data = "";
      this.mimalog = false;
      this.$refs["upload"].$children[0].$refs.input.click();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    sousuo: function () {
      this.search.page = 1;
      if (window.screen.width < 1080) {
        this.list = [];
        this.loading = false;
        this.finished = false;
        this.onLoad();
      } else {
        this.getlist();
      }
    },
    getlist: function () {
      axios
        .get("/own/commission/orders", { params: this.search })
        .then((response) => {
          if (response.data.msg.code == 0) {
            console.log("response123", response);
            this.list = response.data.data.data;
            // this.list.forEach(item=>{
            //   item.selling_point = JSON.parse(item.selling_point)
            // })
            this.total = response.data.data.total;
            this.loading = false;
          } else {
            this.$message.error(response.data.msg.info);
          }
        });
    },
    fanye: function (val) {
      this.search.page = val;
      this.getlist();
    },
    //自动结算配置打开按钮获取配置信息
    zidongjieusan() {
      this.yongjinjiesuanDialog = true;
      axios.get("/own/pay/settlement/get").then((response) => {
        console.log("1010", response);
        if (response.data.msg.code == 0) {
          if (response.data.data == "1") {
            this.isyongjinjiesuan.autovalue = true; //开
          }
          if (response.data.data == "0") {
            this.isyongjinjiesuan.autovalue = false; //关
          }
        }
      });
    },
    //佣金结算（最终）
    yongjinjiesuan() {
      if (this.isyongjinjiesuan.autovalue == true) {
        this.switchshow = "1";
      }
      if (this.isyongjinjiesuan.autovalue == false) {
        this.switchshow = "0";
      }
      let obj = {
        auto_settlement: this.switchshow,
      };
      //  console.log('obj',obj)
      axios.post("/own/pay/settlement/config", obj).then((response) => {
        console.log("response", response);
        if (response.data.msg.code == 0) {
          this.$message.success("配置成功！");
          this.yongjinjiesuanDialog = false;
          this.getlist();
        } else {
          this.$message.error(response.data.msg.info);
          this.yongjinjiesuanDialog = false;
          this.getlist();
        }
      });
    },
    //取消佣金结算
    undoyongjinjiesuan() {
      this.yongjinjiesuanDialog = false;
    },
    changeSwitch(val, row) {
      console.log("val,row", val, row);
      if (val == true) {
        this.switchshow = "1";
      }
      if (val == false) {
        this.switchshow = "0";
      }
    },
  },
};
</script>

<style scoped lang="less"></style>
